from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import requests

app = FastAPI()
base_url = "http://172.195.20.196:8010/api/Hemodialysis/GetBaseInfo"
app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


@app.get("/")
async def root():
    return {"message": "血透 help page"}


@app.get("/patient/{card}")
async def get_patient_info(card: str):
    print(card)
    response = ""
    try:
        response = requests.post(
            base_url, data={"certNo": card, "beginDate": "", "endDate": ""}
        )
    except Exception as e:
        print(e)
    return response.json()
